import math
import random


def monte_carlo_pi(points):
    inside_points = 0
    count = 0
    for i in range(points):
        x, y = random.random(), random.random()
        distance_from_center = math.sqrt(x ** 2 + y ** 2)
        if distance_from_center <= 1.0:
            inside_points += 1
        count += 1
        pi_estimate = 4 * (inside_points / points)
        if count % 1000000 == 0:
            print(f"Estimated value of pi: {pi_estimate}")

    pi_estimate = 4 * (inside_points / points)
    return pi_estimate


# 运行计算，并且设置点的数量为1000000
points = 1000000000000000000000
estimated_pi = monte_carlo_pi(points)
print(f"Estimated value of pi: {estimated_pi}")